from django.db import models


class Question(models.Model):
    question_text = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')

    def __str__(self):
        return self.question_text

        # def was_published_recently(self):
        #     return self.pub_date >= timezone.now() - datetime.timedelta(days=1)


class Choice(models.Model):
    question = models.ForeignKey(Question, on_delete=models.CASCADE)
    choice_text = models.CharField(max_length=200)
    votes = models.IntegerField(default=0)

    def __str__(self):
        return self.choice_text


# model.pyfrom django.db import models

class User(models.Model):
    id = models.AutoField(primary_key=True)  # 创建一个主键
    username = models.CharField(max_length=32)  # 用户名
    password = models.CharField(max_length=8)  # 密码


class report_list(models.Model):
    reportname = models.CharField(max_length=128)
    reportclass = models.CharField(max_length=128, default="")
    reportkey = models.CharField(max_length=128, default="")
    report = models.TextField(max_length=15000)
    report_id = models.AutoField(primary_key=True)
    c_time = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.reportname

    class Meta:
        ordering = ["-c_time"]
        verbose_name = "测试报告"
        verbose_name_plural = "测试报告"


class Test_Interface_List(models.Model):
    id = models.AutoField(primary_key=True)  # 创建一个主键
    entry_name = models.CharField(max_length=255, null=True)  # 项目名称
    Iterative_version = models.CharField(max_length=255, null=True)  # 迭代版本
    modular = models.CharField(max_length=255, null=True)  # 模块
    case_name = models.CharField(max_length=255, null=True)  # case名称

    class Meta:
        db_table = "TestInterfaceList"


class Test_Interface_List_Content(models.Model):
    id = models.AutoField(primary_key=True)  # 主键id
    User_id = models.CharField(max_length=255, null=True)  # 用户id
    url = models.CharField(max_length=400, null=True)  # case_url
    Token = models.TextField(max_length=15000, null=True)  # 用户token
    Request_type = models.CharField(max_length=255, null=True)  # 用户token
    Body = models.TextField(max_length=15000, null=True)  # 请求body
    Headers = models.TextField(max_length=15000, null=True)  # 请求headers
    Transmission_parameters = models.TextField(max_length=15000, null=True)  # 透传参数
    Calibration_parameters = models.TextField(max_length=15000, null=True)  # 校验参数
    Replace_parameter = models.TextField(max_length=15000, null=True)  # 替换参数
    not_in_null = models.TextField(max_length=15000, null=True)  # 是否为空
    Association = models.ForeignKey("Test_Interface_List", on_delete=models.CASCADE, null=True)

    class Meta:
        db_table = "TestInterfaceListContent"
